//
//  JAFCalenderHeader.m
//  JAFDemo
//
//  Created by 阿飞 on 2018/1/24.
//  Copyright © 2018年 阿飞. All rights reserved.
//

#import "JAFCalenderHeader.h"
#import "JAFButton.h"
@interface JAFCalenderHeader ()

@property(nonatomic,strong)JAFButton *leftButton;
@property(nonatomic,strong)UIButton *titleButton;
@property(nonatomic,strong)JAFButton *rightButton;

@end
//获取屏幕 宽度、高度
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
@implementation JAFCalenderHeader 

-(instancetype)initWithFrame:(CGRect)frame withLeftTitle:(NSString *)leftTitle withRightTitle:(NSString *)rightTitle{//withTitle:(NSString *)dateMonth
    self = [super initWithFrame:frame];
    if (self) {
        //前一天
        self.leftButton = [JAFButton LXButtonWithTitle:leftTitle titleFont:[UIFont systemFontOfSize:14] Image:nil backgroundImage:nil backgroundColor:[UIColor  yellowColor] titleColor:[UIColor blackColor] frame:CGRectMake(0, 0, SCREEN_WIDTH/3, SCREEN_HEIGHT*44/667)];
        
        [self.leftButton addTarget:self action:@selector(leftClick:) forControlEvents:UIControlEventTouchUpInside];

        self.titleButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.titleButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.titleButton.backgroundColor = [UIColor yellowColor];
        self.titleButton.frame = CGRectMake(SCREEN_WIDTH/3, 0, SCREEN_WIDTH/3, SCREEN_HEIGHT*44/667);
        self.titleButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.titleButton addTarget:self action:@selector(titleClick:) forControlEvents:UIControlEventTouchUpInside];
       
        self.rightButton = [JAFButton LXButtonWithTitle:rightTitle titleFont:[UIFont systemFontOfSize:14] Image:nil backgroundImage:nil backgroundColor:[UIColor yellowColor] titleColor:[UIColor blackColor] frame:CGRectMake(SCREEN_WIDTH*2/3, 0, SCREEN_WIDTH/3, SCREEN_HEIGHT*44/667)];
        [self.rightButton addTarget:self action:@selector(rightClick:) forControlEvents:UIControlEventTouchUpInside];
      
        [self addSubview:self.rightButton];
        [self addSubview:self.titleButton];
        [self addSubview:self.leftButton];
        
        
    }
    return self;
}
-(void)setDateStr:(NSString *)dateStr{
    
    _dateStr = dateStr;
    
    [self.titleButton setTitle:dateStr forState:UIControlStateNormal];
    
}
-(void)leftClick:(JAFButton *)sender{
    if (self.leftClickBlock) {
        self.leftClickBlock();
    }
}

-(void)titleClick:(UIButton *)sender{
    
    if (self.titleClickBlock) {
        self.titleClickBlock();
    }
}

-(void)rightClick:(JAFButton *)sender{
    if (self.rightClickBlock) {
        self.rightClickBlock();
    }
}



@end
